from flask import Flask,render_template,request,redirect,session


app= Flask(__name__,template_folder='')
app.debug=True
app.secret_key='lszppp'

user_dict={
    '1':{'name':'zhijun','age':18},
    '2':{'name':'zhijun1','age':19}
}

@app.route("/login",methods=["GET","POST"])
def login() :
    if request.method=="GET":
        return render_template('login.html')
    user=request.form.get('user')
    pwd=request.form.get('pws')
    if user=='axex' and pwd=='123':
        session['user_info']=user
        return redirect('/index')


    else:
        return render_template("login.html",msg="用户名或者密码错误")

@app.route('/index')
def index():
    user_info= session.get("user_info")
    if not user_info:
        return redirect('/index')
    return render_template('index.html',User_dict=user_dict)

    return "登录成功了"

@app.route('/detail')

def detail():
    user_info=session.get('user_info')
    if not user_info:
        return redirect('/login')

    uid=request.args.get('uid')


    return render_template('detail.html',user_dict=user_dict)


@app.route('/logout')
def logout():
    del session['user_inf']
    return redirect('/login')


if __name__ == '__main__':
    app.run()


